<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Make Controller Kit - Firmware API: Tasks</title>
<link href="mt_doxygen.css" rel="stylesheet" type="text/css" />
<link href="../resources/mt_doxytabs.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.header {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 12pt;
	color: #222222;
}
-->
</style>
</head>

<body>
<table width="800" border="0">
    <tr>
      <td colspan="3">
        <form method="get" action="http://www.google.com/search">
          <div align="right">
            <input type="text"   name="q" size="25"
              maxlength="255" value="" />
            <input type="submit" value="Search" />
            <input type="hidden" name="sitesearch" value="makingthings.com/ref/firmware/html" />
          </div>
        </form>
       </td>
    </tr>
    <tr>
      <td><div align="center"><a href="http://www.makingthings.com">
				<img src="../resources/logo_brown_medium.png" alt="MakingThings"
									width="200" height="78" border="0" align="middle" longdesc="http://www.makingthings.com" /></a></div></td>
				<td><div align="center" class="header">
      		Make Controller Kit <br />
          Firmware API
      </div></td>
      <td><div align="center"><a href="http://www.makezine.com">
					<img src="../resources/make_logo.png" alt="MAKE Zine" 
										width="164" height="73" border="0" align="middle" longdesc="http://www.makezine.com" /></a></div></td>
    </tr>
</table>
</body>
</html>
<!-- Generated by Doxygen 1.5.4 -->
<script type="text/javascript">
<!--
function changeDisplayState (e){
  var num=this.id.replace(/[^[0-9]/g,'');
  var button=this.firstChild;
  var sectionDiv=document.getElementById('dynsection'+num);
  if (sectionDiv.style.display=='none'||sectionDiv.style.display==''){
    sectionDiv.style.display='block';
    button.src='open.gif';
  }else{
    sectionDiv.style.display='none';
    button.src='closed.gif';
  }
}
function initDynSections(){
  var divs=document.getElementsByTagName('div');
  var sectionCounter=1;
  for(var i=0;i<divs.length-1;i++){
    if(divs[i].className=='dynheader'&&divs[i+1].className=='dynsection'){
      var header=divs[i];
      var section=divs[i+1];
      var button=header.firstChild;
      if (button!='IMG'){
        divs[i].insertBefore(document.createTextNode(' '),divs[i].firstChild);
        button=document.createElement('img');
        divs[i].insertBefore(button,divs[i].firstChild);
      }
      header.style.cursor='pointer';
      header.onclick=changeDisplayState;
      header.id='dynheader'+sectionCounter;
      button.src='closed.gif';
      section.id='dynsection'+sectionCounter;
      section.style.display='none';
      section.style.marginLeft='14px';
      sectionCounter++;
    }
  }
}
window.onload = initDynSections;
-->
</script>
<div class="tabs">
  <ul>
    <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
    <li><a href="modules.html"><span>Modules</span></a></li>
    <li><a href="classes.html"><span>Data&nbsp;Structures</span></a></li>
    <li><a href="files.html"><span>Files</span></a></li>
    <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
  </ul>
</div>
<h1>Tasks<br>
<small>
[<a class="el" href="group___r_t_o_s.html">RTOS</a>]</small>
</h1>The individual "programs" that make up your application.  
<a href="#_details">More...</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___tasks.html#g9a64a7c0e24f257826103d1d1bbb44fa">Sleep</a> (int timems)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Put a task to sleep for a given number of milliseconds.  <a href="#g9a64a7c0e24f257826103d1d1bbb44fa"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___tasks.html#gbe9e0304997a15f46d9eae37be16e3f2">TaskYield</a> ()</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Give up the remaining time allotted to this task by the processor.  <a href="#gbe9e0304997a15f46d9eae37be16e3f2"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___tasks.html#g784f87fb45eebb76d07478036ed228d3">TaskCreate</a> (void(taskCode)(void *), char *name, int stackDepth, void *parameters, int priority)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Create a new task.  <a href="#g784f87fb45eebb76d07478036ed228d3"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___tasks.html#g5bc41573c59208d32d999e2f394ad3ce">TaskDelete</a> (void *task)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Delete an existing task.  <a href="#g5bc41573c59208d32d999e2f394ad3ce"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___tasks.html#gd02e088c48f69fd07cf3157bcceb01b7">TaskEnterCritical</a> ()</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Specify that a task is entering a period during which it should not be interrupted.  <a href="#gd02e088c48f69fd07cf3157bcceb01b7"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___tasks.html#g0911fd273992ff4dec66d096a9dc3257">TaskExitCritical</a> ()</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Specify that a task is exiting a critical period, in response to <a class="el" href="group___tasks.html#gd02e088c48f69fd07cf3157bcceb01b7" title="Specify that a task is entering a period during which it should not be interrupted...">TaskEnterCritical()</a>.  <a href="#g0911fd273992ff4dec66d096a9dc3257"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___tasks.html#gbce595eac3d0cfb96b1cd9037a613ef8">TaskGetRemainingStack</a> (void *task)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Check how much stack is available for a given task.  <a href="#gbce595eac3d0cfb96b1cd9037a613ef8"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___tasks.html#gdd4c687d4df17e7eee740e3e8bc103c8">getTaskByName</a> (char *taskName)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Get a pointer to a task by its name.  <a href="#gdd4c687d4df17e7eee740e3e8bc103c8"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___tasks.html#ge92ca2261fff9550cc18ac991afafd01">getTaskByID</a> (int taskID)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Get a pointer to a task by its ID number.  <a href="#ge92ca2261fff9550cc18ac991afafd01"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___tasks.html#g0b8075007b824b2295dc5d3453a372fb">TaskGetPriority</a> (void *task)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Get the priority of a task.  <a href="#g0b8075007b824b2295dc5d3453a372fb"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___tasks.html#g39806aeaa7dd24062f13c3118ca1b990">TaskGetIDNumber</a> (void *task)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Get the ID number of a task.  <a href="#g39806aeaa7dd24062f13c3118ca1b990"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">char *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___tasks.html#ga15296e2b927abaadce9ed3028917afd">TaskGetName</a> (void *task)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Get the name of a task.  <a href="#ga15296e2b927abaadce9ed3028917afd"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___tasks.html#g7bbfe88356db1ef137b85881a1074e29">TaskGetStackAllocated</a> (void *task)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Read the amount of stack initially allocated for a task.  <a href="#g7bbfe88356db1ef137b85881a1074e29"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___tasks.html#g8026e84bd2096796b7899a35dee6f060">TaskGetCurrent</a> ()</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Get a pointer to the task that's currently running.  <a href="#g8026e84bd2096796b7899a35dee6f060"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___tasks.html#g4f0b02fb8a36b62908efd6b649339d19">TaskGetTopPriorityUsed</a> ()</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Read the highest priority being used by any existing task.  <a href="#g4f0b02fb8a36b62908efd6b649339d19"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___tasks.html#ga8d7aef54edaea894b5f5e9cd6c53eae">TaskGetNext</a> (void *task)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Get a pointer to the task whose ID comes after a given ID.  <a href="#ga8d7aef54edaea894b5f5e9cd6c53eae"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___tasks.html#g87597a6d75dce6de737707604d4267ce">GetNumberOfTasks</a> ()</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Get the total number of tasks that exist at a given moment.  <a href="#g87597a6d75dce6de737707604d4267ce"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___tasks.html#g713d7e60380194c8a1ff830c80f37061">TaskSetPriority</a> (void *task, int priority)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Update the priority of a task.  <a href="#g713d7e60380194c8a1ff830c80f37061"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___tasks.html#gc899bfb04919f3af158289bdcb2901de">TaskGetTickCount</a> (void)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Returns the number of ticks since the scheduler started.  <a href="#gc899bfb04919f3af158289bdcb2901de"></a><br></td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
The individual "programs" that make up your application. 
<p>
Tasks can all be written separately and the RTOS will take of switching between them, making sure they all get the processing time they need. Each task is implemented as a continuous loop, and all tasks have the same signature: <div class="fragment"><pre class="fragment"> <span class="keywordtype">void</span> MyTask( <span class="keywordtype">void</span>* parameters) 
</pre></div> The void* parameters is a value that can be passed in at the time the task is created. Make sure that you put your task to sleep when it's not doing anything so that other tasks can get time as well. Otherwise, the Controller will lock up and none of the other tasks will run.<p>
<dl class="user" compact><dt><b>Example</b></dt><dd><div class="fragment"><pre class="fragment">  <span class="keywordtype">void</span> MyTask( <span class="keywordtype">void</span>* p )
  {
    <span class="comment">// some initialization here</span>
    <span class="keywordtype">int</span> newVal = 0;
    
    <span class="comment">// then just sit in our loop</span>
    <span class="comment">// we're going to turn an LED on whenever an AnalogIn is over a certain value </span>
    <span class="keywordflow">while</span>( 1 )
    {
      newVal = <a class="code" href="group___analog_in.html#g66a6bd10fbb5fc80f32994b756cf0412" title="Read the value of an analog input.">AnalogIn_GetValue</a>( 1 );
      <span class="keywordflow">if</span>( newVal &lt; 512 )
        <a class="code" href="group___app_led.html#gdf0cd1ff241ad17592b9036b674613cc" title="Control an LED on the Application Board.">AppLed_SetState</a>( 0, 1 );
      <span class="keywordflow">else</span>
        <a class="code" href="group___app_led.html#gdf0cd1ff241ad17592b9036b674613cc" title="Control an LED on the Application Board.">AppLed_SetState</a>( 0, 0 );
      <a class="code" href="group___tasks.html#g9a64a7c0e24f257826103d1d1bbb44fa" title="Put a task to sleep for a given number of milliseconds.">Sleep</a>( 100 ); <span class="comment">// wait for 100 milliseconds, allowing other tasks to do their thing</span>
    }
  }
</pre></div></dd></dl>
Notice we don't need to include anything about Ethernet or USB communication, or anything else that might be going on. These are taken care of elsewhere by the RTOS, allowing us to focus on our LED blinking.<p>
More info at <a href="http://www.freertos.org">http://www.freertos.org</a> <hr><h2>Function Documentation</h2>
<a class="anchor" name="g87597a6d75dce6de737707604d4267ce"></a><!-- doxytag: member="rtos.c::GetNumberOfTasks" ref="g87597a6d75dce6de737707604d4267ce" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int GetNumberOfTasks           </td>
          <td>(</td>
          <td class="paramtype">void&nbsp;</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Get the total number of tasks that exist at a given moment. 
<p>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>An integer specifying the number of tasks.</dd></dl>
<dl class="user" compact><dt><b>Example</b></dt><dd><div class="fragment"><pre class="fragment"><span class="keywordtype">int</span> numberOfTasks = <a class="code" href="group___tasks.html#g87597a6d75dce6de737707604d4267ce" title="Get the total number of tasks that exist at a given moment.">GetNumberOfTasks</a>( );
</pre></div> </dd></dl>

<p>Definition at line <a class="el" href="rtos_8c-source.html#l00412">412</a> of file <a class="el" href="rtos_8c-source.html">rtos.c</a>.</p>

</div>
</div><p>
<a class="anchor" name="ge92ca2261fff9550cc18ac991afafd01"></a><!-- doxytag: member="rtos.c::getTaskByID" ref="ge92ca2261fff9550cc18ac991afafd01" args="(int taskID)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void* getTaskByID           </td>
          <td>(</td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>taskID</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Get a pointer to a task by its ID number. 
<p>
Each task is given a unique ID number by freeRTOS. If you know this number, but don't have a pointer to the task, use this function to get a pointer to the task itself. This is a costly function, as it shuts down the scheduler to search for the task, so it should really only be used in a debug setting. <dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>taskID</em>&nbsp;</td><td>An integer specifying the unique ID number given to the task by FreeRTOS </td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>A pointer to the task, or NULL if the task was not found. </dd></dl>
<dl class="see" compact><dt><b>See also:</b></dt><dd><a class="el" href="group___tasks.html#g39806aeaa7dd24062f13c3118ca1b990" title="Get the ID number of a task.">TaskGetIDNumber( )</a> </dd></dl>

<p>Definition at line <a class="el" href="rtos_8c-source.html#l00263">263</a> of file <a class="el" href="rtos_8c-source.html">rtos.c</a>.</p>

</div>
</div><p>
<a class="anchor" name="gdd4c687d4df17e7eee740e3e8bc103c8"></a><!-- doxytag: member="rtos.c::getTaskByName" ref="gdd4c687d4df17e7eee740e3e8bc103c8" args="(char *taskName)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void* getTaskByName           </td>
          <td>(</td>
          <td class="paramtype">char *&nbsp;</td>
          <td class="paramname"> <em>taskName</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Get a pointer to a task by its name. 
<p>
When a task is created, it is initialized with a name. If you don't have a pointer to the task itself but you know its name, you can still get a reference to the task. This is a costly function, as it shuts down the scheduler to search for the task, so it should really only be used in a debug setting. <dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>taskName</em>&nbsp;</td><td>A character string specifying the name of the task to find. </td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>A pointer to the task, or NULL if the task was not found. </dd></dl>
<dl class="see" compact><dt><b>See also:</b></dt><dd><a class="el" href="group___tasks.html#ge92ca2261fff9550cc18ac991afafd01" title="Get a pointer to a task by its ID number.">getTaskByID()</a></dd></dl>
<dl class="user" compact><dt><b>Example</b></dt><dd><div class="fragment"><pre class="fragment"><a class="code" href="group___tasks.html#g784f87fb45eebb76d07478036ed228d3" title="Create a new task.">TaskCreate</a>( MyTask, <span class="stringliteral">"Mine"</span>, 1000, 0, 1 ); <span class="comment">// a task has been created, but we don't have a pointer to it</span>
<span class="keywordtype">void</span> *taskPtr = <a class="code" href="group___tasks.html#gdd4c687d4df17e7eee740e3e8bc103c8" title="Get a pointer to a task by its name.">getTaskByName</a>( <span class="stringliteral">"Mine"</span> ); <span class="comment">// but we can still get a pointer to it by its name</span>
</pre></div> </dd></dl>

<p>Definition at line <a class="el" href="rtos_8c-source.html#l00243">243</a> of file <a class="el" href="rtos_8c-source.html">rtos.c</a>.</p>

</div>
</div><p>
<a class="anchor" name="g9a64a7c0e24f257826103d1d1bbb44fa"></a><!-- doxytag: member="rtos.c::Sleep" ref="g9a64a7c0e24f257826103d1d1bbb44fa" args="(int timems)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void Sleep           </td>
          <td>(</td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>timems</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Put a task to sleep for a given number of milliseconds. 
<p>
This lets the processor give time to other tasks. You'll always want to include some amount of <a class="el" href="group___tasks.html#g9a64a7c0e24f257826103d1d1bbb44fa" title="Put a task to sleep for a given number of milliseconds.">Sleep( )</a> in your tasks to avoid locking up the Controller. <dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>timems</em>&nbsp;</td><td>An integer specifying how long to sleep in milliseconds.</td></tr>
  </table>
</dl>
<dl class="user" compact><dt><b>Example</b></dt><dd><div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> MyTask( <span class="keywordtype">void</span> *p) <span class="comment">// in your task</span>
{
  <span class="keywordflow">while</span>( 1 )
  {
    <a class="code" href="group___led.html#g64a0db609a52e4ef919b13e62f3557a9" title="Control the LED on the MAKE Controller Board.">Led_SetState</a>( 0 ); <span class="comment">// turn the LED off</span>
    <a class="code" href="group___tasks.html#g9a64a7c0e24f257826103d1d1bbb44fa" title="Put a task to sleep for a given number of milliseconds.">Sleep</a>( 900 ); <span class="comment">// leave it off for 900 milliseconds</span>
    <a class="code" href="group___led.html#g64a0db609a52e4ef919b13e62f3557a9" title="Control the LED on the MAKE Controller Board.">Led_SetState</a>( 1 ); <span class="comment">// turn the LED on</span>
    <a class="code" href="group___tasks.html#g9a64a7c0e24f257826103d1d1bbb44fa" title="Put a task to sleep for a given number of milliseconds.">Sleep</a>( 10 ); <span class="comment">// leave it on for 10 milliseconds</span>
  }
}
</pre></div> </dd></dl>

<p>Definition at line <a class="el" href="rtos_8c-source.html#l00107">107</a> of file <a class="el" href="rtos_8c-source.html">rtos.c</a>.</p>

</div>
</div><p>
<a class="anchor" name="g784f87fb45eebb76d07478036ed228d3"></a><!-- doxytag: member="rtos.c::TaskCreate" ref="g784f87fb45eebb76d07478036ed228d3" args="(void(taskCode)(void *), char *name, int stackDepth, void *parameters, int priority)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void* TaskCreate           </td>
          <td>(</td>
          <td class="paramtype">void(taskCode)(void *)&nbsp;</td>
          <td class="paramname">, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">char *&nbsp;</td>
          <td class="paramname"> <em>name</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>stackDepth</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void *&nbsp;</td>
          <td class="paramname"> <em>parameters</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>priority</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Create a new task. 
<p>
When creating a new task, be sure that you allocate it enough stack space. A task must have enough stack space to load any of the potential data structures it will be working with, otherwise it will die and the Controller will crash.<p>
Since FreeRTOS is pre-emptive, higher priority tasks will get processor time before lower priority tasks. The priority level is a bit arbitrary, but choose something that makes sense in relation to the other tasks you have running. Always be sure to block a task when possible, in order to give processor time to other tasks. <dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>taskCode</em>&nbsp;</td><td>A pointer to the function that will run when the task starts. </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>name</em>&nbsp;</td><td>A character string containing the name of the task. </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>stackDepth</em>&nbsp;</td><td>An integer specifying in bytes the size of the task's stack. </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>parameters</em>&nbsp;</td><td>A void* parameter which will be passed into the task at create time. </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>priority</em>&nbsp;</td><td>An integer specifying the task's priority (0 lowest - 7 highest priority). </td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>A pointer to the handle for the newly created task, or NULL if it didn't succeed. </dd></dl>
<dl class="see" compact><dt><b>See also:</b></dt><dd><a class="el" href="group___tasks.html#g5bc41573c59208d32d999e2f394ad3ce" title="Delete an existing task.">TaskDelete( )</a></dd></dl>
<dl class="user" compact><dt><b>Example</b></dt><dd><div class="fragment"><pre class="fragment"><span class="comment">// create the task MyTask, called "Me", with a stack of 1000 bytes, no parameters, at priority 1</span>
<span class="keywordtype">void</span> *taskPtr = <a class="code" href="group___tasks.html#g784f87fb45eebb76d07478036ed228d3" title="Create a new task.">TaskCreate</a>( MyTask, <span class="stringliteral">"Me"</span>, 1000, 0, 1 );

<span class="keywordtype">void</span> MyTask( <span class="keywordtype">void</span> *p) <span class="comment">// in your task</span>
{
  <span class="comment">// set up any variables that you'll need</span>
  <span class="keywordtype">int</span> counter = 0;
  <span class="comment">// then start your continuous loop</span>
  <span class="keywordflow">while</span>( 1 )
  {
    counter++;
    <a class="code" href="group___tasks.html#g9a64a7c0e24f257826103d1d1bbb44fa" title="Put a task to sleep for a given number of milliseconds.">Sleep</a>( 100 );
  }
}
</pre></div> </dd></dl>

<p>Definition at line <a class="el" href="rtos_8c-source.html#l00159">159</a> of file <a class="el" href="rtos_8c-source.html">rtos.c</a>.</p>

</div>
</div><p>
<a class="anchor" name="g5bc41573c59208d32d999e2f394ad3ce"></a><!-- doxytag: member="rtos.c::TaskDelete" ref="g5bc41573c59208d32d999e2f394ad3ce" args="(void *task)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void TaskDelete           </td>
          <td>(</td>
          <td class="paramtype">void *&nbsp;</td>
          <td class="paramname"> <em>task</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Delete an existing task. 
<p>
<a class="el" href="group___tasks.html#g784f87fb45eebb76d07478036ed228d3" title="Create a new task.">TaskCreate( )</a> returns a pointer to the newly created task. You'll need to hang onto this pointer in order to delete the task. <dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>task</em>&nbsp;</td><td>A pointer to the handle of the task to be deleted.</td></tr>
  </table>
</dl>
<dl class="user" compact><dt><b>Example</b></dt><dd><div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> *taskPtr = <a class="code" href="group___tasks.html#g784f87fb45eebb76d07478036ed228d3" title="Create a new task.">TaskCreate</a>( MyTask, <span class="stringliteral">"Me"</span>, 1000, 0, 1 ); <span class="comment">// create a new task</span>
<span class="comment">// ... run the task ...</span>
<a class="code" href="group___tasks.html#g5bc41573c59208d32d999e2f394ad3ce" title="Delete an existing task.">TaskDelete</a>( taskPtr ); <span class="comment">// then delete it</span>
</pre></div> </dd></dl>

<p>Definition at line <a class="el" href="rtos_8c-source.html#l00180">180</a> of file <a class="el" href="rtos_8c-source.html">rtos.c</a>.</p>

</div>
</div><p>
<a class="anchor" name="gd02e088c48f69fd07cf3157bcceb01b7"></a><!-- doxytag: member="rtos.c::TaskEnterCritical" ref="gd02e088c48f69fd07cf3157bcceb01b7" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void TaskEnterCritical           </td>
          <td>(</td>
          <td class="paramtype">void&nbsp;</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Specify that a task is entering a period during which it should not be interrupted. 
<p>
Call this from within your task. Be sure to minimize use of this, and to call <a class="el" href="group___tasks.html#g0911fd273992ff4dec66d096a9dc3257" title="Specify that a task is exiting a critical period, in response to TaskEnterCritical()...">TaskExitCritical()</a> as soon as the task has completed its critical stage. Other tasks can't get any processor time while in this state, and performance might be compromised. <dl class="see" compact><dt><b>See also:</b></dt><dd><a class="el" href="group___tasks.html#g0911fd273992ff4dec66d096a9dc3257" title="Specify that a task is exiting a critical period, in response to TaskEnterCritical()...">TaskExitCritical( )</a> </dd></dl>

<p>Definition at line <a class="el" href="rtos_8c-source.html#l00192">192</a> of file <a class="el" href="rtos_8c-source.html">rtos.c</a>.</p>

</div>
</div><p>
<a class="anchor" name="g0911fd273992ff4dec66d096a9dc3257"></a><!-- doxytag: member="rtos.c::TaskExitCritical" ref="g0911fd273992ff4dec66d096a9dc3257" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void TaskExitCritical           </td>
          <td>(</td>
          <td class="paramtype">void&nbsp;</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Specify that a task is exiting a critical period, in response to <a class="el" href="group___tasks.html#gd02e088c48f69fd07cf3157bcceb01b7" title="Specify that a task is entering a period during which it should not be interrupted...">TaskEnterCritical()</a>. 
<p>
Once the task exits a critical period, FreeRTOS will resume switching this task as usual. <dl class="see" compact><dt><b>See also:</b></dt><dd><a class="el" href="group___tasks.html#gd02e088c48f69fd07cf3157bcceb01b7" title="Specify that a task is entering a period during which it should not be interrupted...">TaskEnterCritical( )</a> </dd></dl>

<p>Definition at line <a class="el" href="rtos_8c-source.html#l00202">202</a> of file <a class="el" href="rtos_8c-source.html">rtos.c</a>.</p>

</div>
</div><p>
<a class="anchor" name="g8026e84bd2096796b7899a35dee6f060"></a><!-- doxytag: member="rtos.c::TaskGetCurrent" ref="g8026e84bd2096796b7899a35dee6f060" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void* TaskGetCurrent           </td>
          <td>(</td>
          <td class="paramtype">void&nbsp;</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Get a pointer to the task that's currently running. 
<p>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>A pointer to the task that's currently running.</dd></dl>
<dl class="user" compact><dt><b>Example</b></dt><dd><div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> *currentTask = <a class="code" href="group___tasks.html#g8026e84bd2096796b7899a35dee6f060" title="Get a pointer to the task that&amp;#39;s currently running.">TaskGetCurrent</a>( );
</pre></div> </dd></dl>

<p>Definition at line <a class="el" href="rtos_8c-source.html#l00355">355</a> of file <a class="el" href="rtos_8c-source.html">rtos.c</a>.</p>

</div>
</div><p>
<a class="anchor" name="g39806aeaa7dd24062f13c3118ca1b990"></a><!-- doxytag: member="rtos.c::TaskGetIDNumber" ref="g39806aeaa7dd24062f13c3118ca1b990" args="(void *task)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int TaskGetIDNumber           </td>
          <td>(</td>
          <td class="paramtype">void *&nbsp;</td>
          <td class="paramname"> <em>task</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Get the ID number of a task. 
<p>
FreeRTOS assigns each task a unique ID number. Use this function to retrieve a particular task's ID number. Task ID numbers are not necessarily sequential. <dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>task</em>&nbsp;</td><td>A pointer to the task. </td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>An integer specifying the task's unique ID within freeRTOS, or -1 on fail.</dd></dl>
<dl class="user" compact><dt><b>Example</b></dt><dd><div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> *taskPtr = <a class="code" href="group___tasks.html#g784f87fb45eebb76d07478036ed228d3" title="Create a new task.">TaskCreate</a>( MyTask, <span class="stringliteral">"Mine"</span>, 1000, 0, 1 );
<span class="keywordtype">int</span> <span class="keywordtype">id</span> = <a class="code" href="group___tasks.html#g39806aeaa7dd24062f13c3118ca1b990" title="Get the ID number of a task.">TaskGetIDNumber</a>( taskPtr );
</pre></div> </dd></dl>

<p>Definition at line <a class="el" href="rtos_8c-source.html#l00305">305</a> of file <a class="el" href="rtos_8c-source.html">rtos.c</a>.</p>

</div>
</div><p>
<a class="anchor" name="ga15296e2b927abaadce9ed3028917afd"></a><!-- doxytag: member="rtos.c::TaskGetName" ref="ga15296e2b927abaadce9ed3028917afd" args="(void *task)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">char* TaskGetName           </td>
          <td>(</td>
          <td class="paramtype">void *&nbsp;</td>
          <td class="paramname"> <em>task</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Get the name of a task. 
<p>
Read back the name a task was given when it was created. <dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>task</em>&nbsp;</td><td>A pointer to the task. </td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>The task's name as a string</dd></dl>
<dl class="user" compact><dt><b>Example</b></dt><dd><div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> *taskPtr = <a class="code" href="group___tasks.html#g784f87fb45eebb76d07478036ed228d3" title="Create a new task.">TaskCreate</a>( MyTask, <span class="stringliteral">"Mine"</span>, 1000, 0, 1 );
<span class="keywordtype">char</span>* name = <a class="code" href="group___tasks.html#ga15296e2b927abaadce9ed3028917afd" title="Get the name of a task.">TaskGetName</a>( taskPtr ); <span class="comment">// will return "Mine"</span>
</pre></div> </dd></dl>

<p>Definition at line <a class="el" href="rtos_8c-source.html#l00322">322</a> of file <a class="el" href="rtos_8c-source.html">rtos.c</a>.</p>

</div>
</div><p>
<a class="anchor" name="ga8d7aef54edaea894b5f5e9cd6c53eae"></a><!-- doxytag: member="rtos.c::TaskGetNext" ref="ga8d7aef54edaea894b5f5e9cd6c53eae" args="(void *task)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void* TaskGetNext           </td>
          <td>(</td>
          <td class="paramtype">void *&nbsp;</td>
          <td class="paramname"> <em>task</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Get a pointer to the task whose ID comes after a given ID. 
<p>
FreeRTOS assigns each task a unique ID number internally. This function will return a pointer to the task with the next ID. Note that this does not necessarily mean that this task will be given processor time next, just that its ID is the next one along in the list of all tasks.<p>
This is an expensive function since it needs to stop the scheduler to search the lists of tasks. It should only really be used in a debug setting. <dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>task</em>&nbsp;</td><td>A pointer to the previous task. </td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>A pointer to the task that's next in the ID list.</dd></dl>
<dl class="user" compact><dt><b>Example</b></dt><dd><div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> *oneTask = <a class="code" href="group___tasks.html#g784f87fb45eebb76d07478036ed228d3" title="Create a new task.">TaskCreate</a>( MyTask, <span class="stringliteral">"Mine"</span>, 1000, 0, 1 );
<span class="keywordtype">void</span> *nextTask = <a class="code" href="group___tasks.html#ga8d7aef54edaea894b5f5e9cd6c53eae" title="Get a pointer to the task whose ID comes after a given ID.">TaskGetNext</a>( oneTask );
</pre></div> </dd></dl>

<p>Definition at line <a class="el" href="rtos_8c-source.html#l00392">392</a> of file <a class="el" href="rtos_8c-source.html">rtos.c</a>.</p>

</div>
</div><p>
<a class="anchor" name="g0b8075007b824b2295dc5d3453a372fb"></a><!-- doxytag: member="rtos.c::TaskGetPriority" ref="g0b8075007b824b2295dc5d3453a372fb" args="(void *task)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int TaskGetPriority           </td>
          <td>(</td>
          <td class="paramtype">void *&nbsp;</td>
          <td class="paramname"> <em>task</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Get the priority of a task. 
<p>
When a task is created, it's given a priority from 1-7. Use this function to get the task's priority after it has been created. <dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>task</em>&nbsp;</td><td>A pointer to the task. </td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>An integer specifying the task's priority</dd></dl>
<dl class="user" compact><dt><b>Example</b></dt><dd><div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> *taskPtr = <a class="code" href="group___tasks.html#g784f87fb45eebb76d07478036ed228d3" title="Create a new task.">TaskCreate</a>( MyTask, <span class="stringliteral">"Mine"</span>, 1000, 0, 1 );
<span class="keywordtype">int</span> priority = <a class="code" href="group___tasks.html#g0b8075007b824b2295dc5d3453a372fb" title="Get the priority of a task.">TaskGetPriority</a>( taskPtr ); <span class="comment">// will return 1</span>
</pre></div> </dd></dl>

<p>Definition at line <a class="el" href="rtos_8c-source.html#l00287">287</a> of file <a class="el" href="rtos_8c-source.html">rtos.c</a>.</p>

</div>
</div><p>
<a class="anchor" name="gbce595eac3d0cfb96b1cd9037a613ef8"></a><!-- doxytag: member="rtos.c::TaskGetRemainingStack" ref="gbce595eac3d0cfb96b1cd9037a613ef8" args="(void *task)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int TaskGetRemainingStack           </td>
          <td>(</td>
          <td class="paramtype">void *&nbsp;</td>
          <td class="paramname"> <em>task</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Check how much stack is available for a given task. 
<p>
When a task is created, it is initialized with a stack depth. This function will return the numbers of bytes available from that initial allocation. <dl class="return" compact><dt><b>Returns:</b></dt><dd>An integer specifying the available stack in bytes. </dd></dl>
<dl class="see" compact><dt><b>See also:</b></dt><dd><a class="el" href="group___tasks.html#g7bbfe88356db1ef137b85881a1074e29" title="Read the amount of stack initially allocated for a task.">TaskGetStackAllocated( )</a></dd></dl>
<dl class="user" compact><dt><b>Example</b></dt><dd><div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> *taskPtr = <a class="code" href="group___tasks.html#g784f87fb45eebb76d07478036ed228d3" title="Create a new task.">TaskCreate</a>( MyTask, <span class="stringliteral">"Mine"</span>, 1000, 0, 1 ); <span class="comment">// create a new task</span>
<span class="keywordtype">int</span> freeBytes = <a class="code" href="group___tasks.html#gbce595eac3d0cfb96b1cd9037a613ef8" title="Check how much stack is available for a given task.">TaskGetRemainingStack</a>( taskPtr ); <span class="comment">// check how much of the task's stack has been used</span>
</pre></div> </dd></dl>

<p>Definition at line <a class="el" href="rtos_8c-source.html#l00220">220</a> of file <a class="el" href="rtos_8c-source.html">rtos.c</a>.</p>

</div>
</div><p>
<a class="anchor" name="g7bbfe88356db1ef137b85881a1074e29"></a><!-- doxytag: member="rtos.c::TaskGetStackAllocated" ref="g7bbfe88356db1ef137b85881a1074e29" args="(void *task)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int TaskGetStackAllocated           </td>
          <td>(</td>
          <td class="paramtype">void *&nbsp;</td>
          <td class="paramname"> <em>task</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Read the amount of stack initially allocated for a task. 
<p>
Each task is allocated a certain amount of stack space when it's created. Use this function to determine how much stack space a task was originally given. <dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>task</em>&nbsp;</td><td>A pointer to the task. </td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>An integer specifying the amount of stack, in bytes, that this task was allocated. </dd></dl>
<dl class="see" compact><dt><b>See also:</b></dt><dd><a class="el" href="group___tasks.html#gbce595eac3d0cfb96b1cd9037a613ef8" title="Check how much stack is available for a given task.">TaskGetRemainingStack( )</a></dd></dl>
<dl class="user" compact><dt><b>Example</b></dt><dd><div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> *taskPtr = <a class="code" href="group___tasks.html#g784f87fb45eebb76d07478036ed228d3" title="Create a new task.">TaskCreate</a>( MyTask, <span class="stringliteral">"Mine"</span>, 1000, 0, 1 );
<span class="keywordtype">int</span> stack = <a class="code" href="group___tasks.html#g7bbfe88356db1ef137b85881a1074e29" title="Read the amount of stack initially allocated for a task.">TaskGetStackAllocated</a>( taskPtr ); <span class="comment">// will return 1000</span>
</pre></div> </dd></dl>

<p>Definition at line <a class="el" href="rtos_8c-source.html#l00341">341</a> of file <a class="el" href="rtos_8c-source.html">rtos.c</a>.</p>

</div>
</div><p>
<a class="anchor" name="gc899bfb04919f3af158289bdcb2901de"></a><!-- doxytag: member="rtos.c::TaskGetTickCount" ref="gc899bfb04919f3af158289bdcb2901de" args="(void)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int TaskGetTickCount           </td>
          <td>(</td>
          <td class="paramtype">void&nbsp;</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Returns the number of ticks since the scheduler started. 
<p>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>the number of ticks </dd></dl>

<p>Definition at line <a class="el" href="rtos_8c-source.html#l00439">439</a> of file <a class="el" href="rtos_8c-source.html">rtos.c</a>.</p>

</div>
</div><p>
<a class="anchor" name="g4f0b02fb8a36b62908efd6b649339d19"></a><!-- doxytag: member="rtos.c::TaskGetTopPriorityUsed" ref="g4f0b02fb8a36b62908efd6b649339d19" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int TaskGetTopPriorityUsed           </td>
          <td>(</td>
          <td class="paramtype">void&nbsp;</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Read the highest priority being used by any existing task. 
<p>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>An integer specifying the priority.</dd></dl>
<dl class="user" compact><dt><b>Example</b></dt><dd><div class="fragment"><pre class="fragment"><span class="keywordtype">int</span> highestPriority = <a class="code" href="group___tasks.html#g4f0b02fb8a36b62908efd6b649339d19" title="Read the highest priority being used by any existing task.">TaskGetTopPriorityUsed</a>( );
</pre></div> </dd></dl>

<p>Definition at line <a class="el" href="rtos_8c-source.html#l00369">369</a> of file <a class="el" href="rtos_8c-source.html">rtos.c</a>.</p>

</div>
</div><p>
<a class="anchor" name="g713d7e60380194c8a1ff830c80f37061"></a><!-- doxytag: member="rtos.c::TaskSetPriority" ref="g713d7e60380194c8a1ff830c80f37061" args="(void *task, int priority)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void TaskSetPriority           </td>
          <td>(</td>
          <td class="paramtype">void *&nbsp;</td>
          <td class="paramname"> <em>task</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>priority</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Update the priority of a task. 
<p>
Higher numbers mean higher priority/more processor time. <dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>task</em>&nbsp;</td><td>A pointer to the task you want to update. </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>priority</em>&nbsp;</td><td>An integer specifying the new priority.</td></tr>
  </table>
</dl>
<dl class="user" compact><dt><b>Example</b></dt><dd><div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> *task = <a class="code" href="group___tasks.html#g784f87fb45eebb76d07478036ed228d3" title="Create a new task.">TaskCreate</a>( MyTask, <span class="stringliteral">"Mine"</span>, 1000, 0, 1 ); <span class="comment">// create a task</span>
<span class="comment">// ... now update the task's priority to 6</span>
<a class="code" href="group___tasks.html#g713d7e60380194c8a1ff830c80f37061" title="Update the priority of a task.">TaskSetPriority</a>( task, 6 );
</pre></div> </dd></dl>

<p>Definition at line <a class="el" href="rtos_8c-source.html#l00430">430</a> of file <a class="el" href="rtos_8c-source.html">rtos.c</a>.</p>

</div>
</div><p>
<a class="anchor" name="gbe9e0304997a15f46d9eae37be16e3f2"></a><!-- doxytag: member="rtos.c::TaskYield" ref="gbe9e0304997a15f46d9eae37be16e3f2" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void TaskYield           </td>
          <td>(</td>
          <td class="paramtype">void&nbsp;</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Give up the remaining time allotted to this task by the processor. 
<p>
The presently running task immeidately gives up the remaining time it has in the current timeslice so that other tasks can run. While <a class="el" href="group___tasks.html#g9a64a7c0e24f257826103d1d1bbb44fa" title="Put a task to sleep for a given number of milliseconds.">Sleep()</a> will wait the specified number of milliseconds before continuing, <a class="el" href="group___tasks.html#gbe9e0304997a15f46d9eae37be16e3f2" title="Give up the remaining time allotted to this task by the processor.">TaskYield()</a> will cause the task to take processor time again as soon as it's available. 
<p>Definition at line <a class="el" href="rtos_8c-source.html#l00119">119</a> of file <a class="el" href="rtos_8c-source.html">rtos.c</a>.</p>

</div>
</div><p>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Make Controller Kit</title>
<style type="text/css">
<!--
.footer {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 9pt;
	color: #999999;
}
-->
</style>
</head>

<body>
<hr size="1">
<div>
  <p class="footer">The Make Controller Kit is an open source project maintained by <a href="http://www.makingthings.com">MakingThings</a>.<br />
    MakingThings code is released under the <a href="http://www.apache.org/licenses/LICENSE-2.0.html" target="_blank">Apache 2.0 license</a>.<br />
    Bug tracker, development wiki and status can be found at <a href="http://dev.makingthings.com">http://dev.makingthings.com</a>.<br />
		This document was last updated on 5 Dec 2007.
</p>
</div>
<!-- Google Analytics Code -->
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-769030-1";
urchinTracker();
</script>
</body>
</html>
